import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { PersonList } from '../Common/Conversion'

export const TunnelUwbCard = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        type: '隧道管理',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '9b65d555-7e44-40d7-af5c-52ff950d7fd3') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: ['person', 'organization', 'uuid'],
                title: '组织机构',
                key: 'OrganizationUuid',
                valueType: 'select',
                valueEnum: ClientData.organization,
                width: 150,
                hideInAdded: true,
                hideInSearch: true,
                hideInModify: true,
            },
            {
                dataIndex: 'organizationUuid',
                title: '组织机构',
                valueType: 'select',
                valueEnum: {},
                width: 150,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            {
                dataIndex: 'tableName',
                title: '名称',
                valueType: 'input',
                width: 150,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'deviceSerial',
                title: '卡序列号',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'personUuid',
                title: '人员信息',
                valueType: 'select',
                valueEnum: await PersonList(),
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'personName',
                title: '人员信息',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '2b1b2208-76a3-428f-8579-6c727f9f30ed') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '9a1e3615-c624-45a2-a09b-e3403c4bf316') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
